import * as resume from '@/api/resume.js'
export default {
	name: 'Education',
	props: {

	},
	components: {

	},
	data() {
		return {
			id: 0,
			form: {
				id: '',
				name: '',
				profession: '',
				start_time: '请选择',
				up_time: '请选择',
				drving_index: -1,
				drving: 0,
				drving_name: '',
			},
			drving_arr: [],
			name_null: false,
			drving_null: false,
			profession_null: false,
			date_null: false,
			update_null: false,
			deleteShow: false, //删除按钮显示
		}
	},
	onLoad(params) {
		if (params.item) {
			this.getEducate(JSON.parse(params.item))
		}
		this.getDrvingList()
		// this.getEducate()
	},
	onLaunch() {},
	methods: {
		//获取详情
		getEducate(res) {
			// Educate({id: this.form.id}).then(res=>{
			console.log(res);
			this.deleteShow = true
			// this.form = res
			this.form.id = res.id
			this.form.name = res.name
			this.form.profession = res.profession
			this.form.drving_name = res.drving_text
			this.form.drving = res.drving
			this.form.start_time = res.start_text || '请选择'
			this.form.up_time = res.up_text || '请选择'
			this.form.drving = res.drving
			// })
		},
		DateChange(e) {
			console.log(e.detail.value);
			console.log(this.form.start_time);
			this.form.start_time = e.detail.value
		},
		DateChangeup(e) {
			this.form.up_time = e.detail.value
		},
		Pickerdrving(e) {
			this.form.drving_index = e.detail.value
			this.form.drving = this.drving_arr[e.detail.value]['id'];
			this.form.drving_name = this.drving_arr[e.detail.value]['title'];;
		},
		// 删除按钮
		deleteBnt() {
			let that = this
			uni.showModal({
				title: '提示',
				content: '确定删除该经历吗?',
				success: (res) => {
					if (res.confirm) {
						resume.delMemberResumeEducate({
							id: that.form.id
						}).then(res => {
							uni.navigateBack({
								data: 1
							})
						})
					}
				}
			})
		},
		ok_form() {
			var that = this
			if (that.form.name == '') {
				that.name_null = true;
				console.log(that.name_null)
				uni.$u.toast('请输入公司名称');
				return
			}
			if (that.form.drving_name == '') {
				that.drving_null = true;
				uni.$u.toast('请选择学历');
				return;
			}
			// if(that.form.profession == ''){
			// 	that.profession_null = true;
			// 	uni.$u.toast('请输入专业名称');return;
			// }

			if (that.form.start_time == '请选择') {
				that.date_null = true;
				uni.$u.toast('请选择开始时间');
				return;
			}
			if (that.form.up_time == '请选择') {
				that.update_null = true;
				uni.$u.toast('请选择开始时间');
				return;
			}
			resume.editMemberResumeEducate(that.form).then(res => {
				this.$tools.succend('保存成功!')
				setTimeout(res=>{
					uni.navigateBack({
						data: 1
					})
				},500)
			})
		},
		//获取学历要求
		getDrvingList() {
			resume.getDrvingList().then(res => {
				this.drving_arr = res.data
			})
		}
	}
}
